package com.umeox.watch.moto.pedometer.base;

import android.os.Parcel;
import android.os.Parcelable;

import androidx.annotation.NonNull;

import com.dbflow5.annotation.Column;
import com.dbflow5.annotation.PrimaryKey;
import com.dbflow5.annotation.Table;
import com.dbflow5.structure.BaseModel;

@Table(database = BaseDatabase.class, name = StepInfo.TABLE_NAME)
public class StepInfo extends BaseModel implements Parcelable {
    public static final String TABLE_NAME = "step_info";

    public static final Creator<StepInfo> CREATOR = new Creator<StepInfo>() {
        @Override
        public StepInfo createFromParcel(Parcel source) {
            return new StepInfo(source);
        }

        @Override
        public StepInfo[] newArray(int size) {
            return new StepInfo[size];
        }
    };
    @NonNull
    @Column
    @PrimaryKey
    private int stepTime;
    @Column
    private int stepValue;
    @Column
    private int planValue;
    @Column
    private int stepDistance;//步长（单位：厘米）
    @Column
    private int distance;//运动距离（单位：米）
    @Column
    private float calory;//消耗卡路里（单位：大卡）

    public StepInfo() {
    }

    protected StepInfo(Parcel in) {
        readFromParcel(in);
    }

    protected StepInfo(Builder builder) {
        this.stepTime = builder.getStepTime();
        this.stepValue = builder.getStepValue();
        this.planValue = builder.getPlanValue();
        this.stepDistance = builder.getStepDistance();
        this.distance = builder.getDistance();
        this.calory = builder.getCalory();
    }

    public static Builder newBuilder() {
        return new Builder();
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeInt(this.stepTime);
        dest.writeInt(this.stepValue);
        dest.writeInt(this.planValue);
        dest.writeInt(this.stepDistance);
        dest.writeInt(this.distance);
        dest.writeFloat(this.calory);
    }

    public void readFromParcel(Parcel in) {
        this.stepTime = in.readInt();
        this.stepValue = in.readInt();
        this.planValue = in.readInt();
        this.stepDistance = in.readInt();
        this.distance = in.readInt();
        this.calory = in.readFloat();
    }

    public int getStepTime() {
        return stepTime;
    }

    public void setStepTime(int stepTime) {
        this.stepTime = stepTime;
    }

    public int getStepValue() {
        return stepValue;
    }

    public void setStepValue(int stepValue) {
        this.stepValue = stepValue;
    }

    public int getPlanValue() {
        return planValue;
    }

    public void setPlanValue(int planValue) {
        this.planValue = planValue;
    }

    public int getStepDistance() {
        return stepDistance;
    }

    public void setStepDistance(int stepDistance) {
        this.stepDistance = stepDistance;
    }

    public int getDistance() {
        return distance;
    }

    public void setDistance(int distance) {
        this.distance = distance;
    }

    public float getCalory() {
        return calory;
    }

    public void setCalory(float calory) {
        this.calory = calory;
    }

    @Override
    public String toString() {
        return "StepInfo{" +
                "stepTime=" + stepTime +
                ", stepValue=" + stepValue +
                ", planValue=" + planValue +
                ", stepDistance=" + stepDistance +
                ", distance=" + distance +
                ", calory=" + calory +
                '}';
    }

    public static class Builder {
        private int stepTime;
        private int stepValue;
        private int planValue;
        private int stepDistance;
        private int distance;
        private float calory;
        private int stepCount;//记步芯片数据
        private double speed;//速度，公里/小时

        public int getStepTime() {
            return stepTime;
        }

        public Builder setStepTime(int stepTime) {
            this.stepTime = stepTime;
            return this;
        }

        public int getStepValue() {
            return stepValue;
        }

        public Builder setStepValue(int stepValue) {
            this.stepValue = stepValue;
            return this;
        }

        public int getPlanValue() {
            return planValue;
        }

        public Builder setPlanValue(int planValue) {
            this.planValue = planValue;
            return this;
        }

        public int getStepDistance() {
            return stepDistance;
        }

        public Builder setStepDistance(int stepDistance) {
            this.stepDistance = stepDistance;
            return this;
        }

        public int getDistance() {
            return distance;
        }

        public Builder setDistance(int distance) {
            this.distance = distance;
            return this;
        }

        public float getCalory() {
            return calory;
        }

        public Builder setCalory(float calory) {
            this.calory = calory;
            return this;
        }

        public int getStepCount() {
            return stepCount;
        }

        public Builder setStepCount(int stepCount) {
            this.stepCount = stepCount;
            return this;
        }

        public double getSpeed() {
            return speed;
        }

        public Builder setSpeed(double speed) {
            this.speed = speed;
            return this;
        }

        public StepInfo build() {
            return new StepInfo(this);
        }

        @Override
        public String toString() {
            return "Builder{" +
                    "stepTime=" + stepTime +
                    ", stepValue=" + stepValue +
                    ", planValue=" + planValue +
                    ", stepDistance=" + stepDistance +
                    ", distance=" + distance +
                    ", calory=" + calory +
                    '}';
        }
    }

}
